Machine control device

ABSTRACT

A machine control device includes an imaging control unit that controls an imaging device to capture two images at two different imaging positions; an imaging position information acquiring unit that acquires positional information of two imaging positions; a measurement distance restoring unit that restores a measurement distance of an object based on two images, distance information between two imaging positions, and a parameter of the imaging device, by using a stereo camera method; a measurement precision calculating unit that calculates a measurement precision of the measurement distance of the object based on two images, the distance information between two imaging positions, and the parameter of the imaging device; an area specifying unit that specifies a partial area of the object as a specified area; and a measurement precision determining unit that determines whether the measurement precision of the object satisfies a predetermined precision in the specified area.

This application is based on and claims the benefit of priority fromJapanese Patent Application No. 2019-018744, filed on 5 Feb. 2019, thecontent of which is incorporated herein by reference.

BACKGROUND OF THE INVENTION Field of the Invention

The present invention relates to a machine control device that controlsmachine tools or machines such as industrial robots.

Related Art

For example, there is a numerical control device of a machine tool thatperforms machining (predetermined processing) such as cutting on aworkpiece (object) by using a tool. In such a numerical control device,when controlling the relative position between the tool and theworkpiece, it is expected to use information of the position andorientation of the workpiece based on an image of the workpiece taken bya vision sensor (imaging device) (for example, refer to Japanese PatentNo. 2889011).

Patent Document 1: Japanese Patent No. 2889011

SUMMARY OF THE INVENTION

Compared to the machining precision of the numerical control device ofthe machine tool, the measurement precision of the vision sensor is low.Therefore, if the information of the position and orientation of theworkpiece based on the image of the workpiece imaged by the visionsensor is used for positioning of the workpiece without considering themeasurement precision of the vision sensor, collision between the tooland the workpiece may occur, and the tool or the workpiece may bedamaged.

It is an object of the present invention to provide a machine controldevice for enhancing safety in a machine control device for controllinga machine based on an image of an object imaged by an imaging device.

A first aspect of a machine control device according to the presentinvention is a machine control device (for example, a machine controldevice 10 described later) that controls a machine performing apredetermined operation on an object (for example, a work W describedlater), the machine control device being configured to control arelative position of the machine and the object based on an imageincluding the object imaged by an imaging device (for example, a visionsensor 2 described later), the machine control device including: animaging control unit (for example, an imaging control unit 11 describedlater) that controls a position and orientation of the imaging device,and controls the imaging device to capture two or more images includingthe object at two or more different imaging positions based on a controlcommand; an imaging position information acquiring unit (for example, animaging position information acquiring unit 13) that acquires positionalinformation of the two or more imaging positions; a measurement distancerestoring unit (for example, a measurement distance restoring unit 14)that restores a measurement distance of the object as positionalinformation of the object based on at least two images among the two ormore images, distance information between at least two imaging positionscorresponding to the at least two images among the two or more imagingpositions, and a parameter of the imaging device, by using a stereocamera method; a measurement precision calculating unit (for example, ameasurement precision calculating unit 15) that calculates a measurementprecision of the measurement distance of the object based on the atleast two images, the distance information between the at least twoimaging positions, and the parameter of the imaging device; an areaspecifying unit (for example, an area specifying unit 12) that specifiesa partial area of the object as a specified area; and a measurementprecision determining unit (for example, a measurement precisiondetermining unit 16) that determines whether the measurement precisionof the object satisfies a predetermined precision in the specified area.

According to a second aspect of the present invention, in the machinecontrol device as described in the first aspect, the measurementdistance restoring unit may obtain parallax information Z for each pixelby performing area matching on the at least two images, and maycalculate a measurement distance H of the object by equation (1) belowbased on the parallax information Z for the each pixel, distanceinformation between the at least two imaging positions D, and a focaldistance f which is the parameter of the imaging device, and themeasurement precision calculating unit (15) may calculate a measurementprecision P of the measurement distance of the object by equation (2)below, which calculates a difference of the measurement distance H froman adjacent pixel by differentiating the measurement distance H by theparallax information Z,

H=D×f/Z  (1),

P=|dH/dZ|=D×f/Z ² =H ²/(D×f)  (2).

According to a third aspect of the present invention, the machinecontrol device as described in the first aspect or the second aspect maystop control of the machine when the measurement precision of the object(W) does not satisfy the predetermined precision.

According to a fourth aspect of the present invention, the machinecontrol device as described in the first aspect or the second aspect,when the measurement precision of the object does not satisfy thepredetermined precision, the machine control device may control theposition and orientation of the imaging device and changes at least oneof the at least two imaging positions so as to enhance the measurementprecision of the object.

According to a fifth aspect of the present invention, the machinecontrol device as described in the fourth aspect may control theposition of the imaging device in a direction increasing a distancebetween the at least two imaging positions or in a direction bringingthe imaging position close to the object to thereby enhance themeasurement precision of the object when the measurement precision ofthe object does not satisfy the predetermined precision.

According to a sixth aspect of the present invention, the machinecontrol device as described in the fourth aspect or the fifth aspect mayfurther include a predetermined precision position calculating unit (forexample, a predetermined precision position calculating unit 17) thatcalculates distance information between the at least two imagingpositions at which the measurement precision of the object satisfies apredetermined precision based on the at least two images, themeasurement distance of the object, and the parameter of the imagingdevice, or calculates a measurement distance of the object at which themeasurement precision of the object satisfies a predetermined precisionbased on the at least two images, the distance information between theat least two imaging positions, and the parameter of the imaging devicein the specified area, in which the machine control device may controlthe position and orientation of the imaging device based on the distanceinformation between the at least two imaging positions or themeasurement distance of the object calculated by the predeterminedprecision position calculating unit, and may change at least one of theat least two imaging positions.

According to a seventh aspect of the present invention, in the machinecontrol device as described in the sixth aspect, the measurementdistance restoring unit may obtain parallax information Z for each pixelby performing area matching on the at least two images, and maycalculate a measurement distance H of the object by equation (1) belowbased on the parallax information Z for the each pixel, distanceinformation between the at least two imaging positions D, and a focaldistance f which is a parameter of the imaging device, and thepredetermined precision position calculating unit calculates a distanceD′ between the at least two imaging positions at which the measurementprecision of the object satisfies a predetermined precision P′ byequation (3) below based on a measurement distance H of the object and afocal distance f which is a parameter of the imaging device, orcalculates a measurement distance H′ of the object at which themeasurement precision of the object satisfies the predeterminedprecision P′ by a following equation (4) based on the distance betweenthe at least two imaging positions D and the focal distance f which isthe parameter of the imaging device,

H=D×f/Z  (1),

P′=H ²/(D′×f)  (3),

P′=H′ ²/(D×f)  (4).

According to the present invention, it is possible to provide a machinecontrol device for enhancing safety in a machine control device forcontrolling a machine based on an image of an object imaged by animaging device.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a diagram showing a main part of a machine control device of amachine tool according to a first embodiment as one embodiment of thepresent invention;

FIG. 2 is a diagram for explaining control of a vision sensor by themachine control device;

FIG. 3 is a diagram for explaining restoration of a measurement distanceof a workpiece by using the stereo camera method;

FIG. 4 is a diagram for explaining a calculation of two imagingpositions (moving amounts) satisfying a target precision by the machinecontrol device;

FIG. 5 is a diagram showing an example of a program for controlling thevision sensor by the machine control device (left portion) andexplanations thereof (right portion);

FIG. 6 is a diagram for explaining a calculation of two imagingpositions (moving amounts) satisfying a target precision by the machinecontrol device according to a modification example; and

FIG. 7 is a diagram showing an example of a program for controlling thevision sensor by the machine control device according to a modificationexample (left portion) and explanations thereof (right portion).

DETAILED DESCRIPTION OF THE INVENTION

In the following, an example of an embodiment of the present inventionwill be described with reference to the attached drawings. It should benoted that the same reference symbols will be attached to identical orcorresponding portions in the respective drawings.

First Embodiment

FIG. 1 is a diagram showing a main part of a machine control device of amachine tool according to a first embodiment as one embodiment. Amachine control device 10 shown in FIG. 1 is a numerical control devicethat controls a machine tool for performing a predetermined operation(for example, machining such as cutting) on a workpiece (object) W. Insuch an operation, the machine control device 10 recognizes a positionof the workpiece W based on an image including the workpiece W imaged bya vision sensor (visual sensor, imaging device) 2, and controls therelative position of a tool T and the workpiece W of the machine tool.For example, the machine control device 10 may control the position ofthe tool T of the machine tool, or alternatively, may control theposition of the workpiece W. When the vision sensor 2 is mounted in thevicinity of the tool T of the machine tool, the movement command of thetool T of the machine tool and the movement command of the vision sensor2 can be made identical. Hereinafter, the control of the vision sensor 2by the machine control device 10 will be described in detail.

The machine control device 10 is configured by, for example, anarithmetic processor such as a CPU (Central Processing Unit) and a DSP(Digital Signal Processor). The various functions of the machine controldevice 10 are realized by executing predetermined software (programs,applications) stored in a storage unit, for example. The variousfunctions of the machine control device 10 may be realized by thecooperation of hardware and software, or may be realized by only FPGA(Field Programmable Gate Array or hardware (electronic circuits)).

The machine control device 10 includes an imaging control unit 11, anarea specifying unit 12, an imaging position information acquiring unit13, a measurement distance restoring unit 14, a measurement precisioncalculating unit 15, a measurement precision determining unit 16, and apredetermined precision position calculating unit 17.

FIG. 2 is a diagram for explaining the control of the vision sensor 2 bythe machine control device 10. As shown in FIG. 2, the imaging controlunit 11 controls the position and orientation of the vision sensor 2,and controls the vision sensor 2 so as to capture two images includingthe workpiece W at two different imaging positions based on, forexample, a control command stored in a storage unit (not shown). Forexample, the imaging control unit 11 causes the vision sensor 2 to movein a predetermined direction, and performs imaging of the workpiece W bythe vision sensor 2 at two imaging positions of a distance betweenimaging positions D (hereinafter, also referred to as an inter-viewpointdistance)

In the two images, the area specifying unit 12 specifies a partial areaof the workpiece W as a specified area (hereinafter, also referred to asa specified pixel or a pixel of interest). The specified area may be anarea of a workpiece manually specified by the user based on a capturedimage displayed on the display unit or the like, or may be an area of aworkpiece automatically specified by image processing of the capturedimage (for example, feature point extraction algorithms).

The imaging position information acquiring unit 13 acquires positionalinformation of two imaging positions (for example, coordinates XYZ onthe camera coordinate system or the machine coordinate system) from theabove-described control command. It should be noted that the imagingposition information acquiring unit 13 may acquire coordinates beforeand after the movement from the machine control device 10.

The measurement distance restoring unit 14 restores the measurementdistance of the workpiece W as the positional information of theworkpiece W based on the two images, the distance information betweenthe two imaging positions, and the parameters of the vision sensor 2 byusing the stereo camera method. FIG. 3 is a diagram for explaining therestoration of the measurement distance of the workpiece by using thestereo camera method. As shown in FIG. 3, the measurement distancerestoring unit 14 obtains the parallax Z for each pixel by performingarea matching on the two images, and calculates the measurement distanceH of the workpiece W by the following equation (1) based on the parallaxZ for each pixel, the distance between the two imaging positions D, andthe focal distance f which is a parameter of the vision sensor 2.

H=D×f/Z  (1)

Here, the machine control device 10 recognizes the position of theworkpiece W based on the image including the workpiece W imaged by thevision sensor 2, and controls the relative position between the tool Tand the workpiece W of the machine tool.

Compared to the machining precision of the numerical control device ofthe machine tool, the measurement precision of the vision sensor 2 islower. Therefore, if the information of the position and orientation ofthe workpiece W based on the image of the workpiece W captured by thevision sensor 2 is used for, for example, positioning the workpiece Wwithout considering the measurement precision of the vision sensor 2,collision between the tool T and the workpiece W may occur, and the toolT or the workpiece W may be damaged. Therefore, the machine controldevice 10 of the present embodiment includes the measurement precisioncalculating unit 15, the measurement precision determining unit 16, andthe predetermined precision position calculating unit 17, in addition tothe measurement distance restoring unit 14.

The measurement precision calculating unit 15 calculates the measurementprecision P of the measurement distance of the workpiece W based on thetwo images, the distance information between the two imaging positions,and the parameters of the vision sensor 2 by using the stereo cameramethod. The measurement precision P is defined by how much differenceoccurs when it is assumed that the workpiece W displayed on aphotographing surface is erroneously displayed on the adjacent pixel(the parallax at this time is defined as Z′) (refer to the followingequation (2)). In other words, the measurement precision P is a valueobtained by differentiating the measurement distance H by Z.

P=|H(Z′)−H(Z)|=|dH/dZ|=D×f/Z ²

The above equation (1) is substituted for this, and the measurementprecision P is represented by the following equation (2).

P=H ²/(D×f)  (2)

From this, it can be understood that the measurement precision P issmaller as the distance between the two imaging positions D is larger,and thus, the precision is high.

The measurement precision determining unit 16 determines whether or notthe measurement precision P of the workpiece W satisfies the targetprecision P′ (predetermined precision, hereinafter, referred to asspecified precision) in the specified area. The target precision P′ maybe a predetermined value, and may be stored in a storage unit or thelike.

The predetermined precision position calculation unit 17 calculates twoimaging positions at which the measurement precision P of the workpieceW satisfies the target precision P′. For example, the predeterminedprecision position calculating unit 17 calculates two imaging positionswhere the measurement precision P of the workpiece W satisfies thetarget precision P′ based on the two images and the parameters of thevision sensor 2. More specifically, the predetermined precision positioncalculating unit 17 calculates distance information between two imagingpositions at which the measurement precision of the workpiece Wsatisfies a predetermined precision based on the two images, themeasurement distance of the workpiece W, and the parameters of thevision sensor 2 in the specified area.

FIG. 4 is a diagram for explaining the calculation of two imagingpositions (moving amounts) satisfying the target precision P′ by themachine control device 10. For example, the predetermined precisionposition calculating unit 17 calculates the distance between two imagingpositions D′ at which the measurement precision of the workpiece Wsatisfies the predetermined precision P′ by the following equation (3)based on the measurement distance H of the workpiece W and the focaldistance f which is a parameter of the imaging device.

P′=H ²/(D′×f)  (3)

Thus, the moving distance E from the state of the inter-viewpointdistance D is obtained by the following equation.

E=D′−D

Alternatively, the predetermined precision position calculating unit 17may calculate the measurement distance of the workpiece W at which themeasurement precision of the workpiece W satisfies a predeterminedprecision based on the two images, the distance information between thetwo imaging positions, and the parameters of the vision sensor 2 in thespecified area. For example, the predetermined precision positioncalculating unit 17 may calculate the measurement distance H′ of theworkpiece W at which the measurement precision of the workpiece Wsatisfies the predetermined precision P′ by the following equation (4)based on the distance between the two imaging positions D and the focaldistance f which is a parameter of the vision sensor 2.

P′=H′ ²/(D×f)  (4)

As described above, the measurement precision is improved by increasingthe inter-viewpoint distance D. Alternatively, the measurement precisionis improved by making the inter-viewpoint distance D constant andbringing the vision sensor 2 close to the workpiece W.

When the measurement precision of the workpiece W satisfies the targetprecision, the machine control device 10 controls the relative positionsof the tool T and the workpiece W of the machine tool based on theposition information of the workpiece W calculated by the positioncalculating unit 14, and performs a predetermined operation on theworkpiece W by using the tool T.

On the other hand, when the measurement precision of the workpiece Wdoes not satisfy the target precision, the machine control device 10performs the following processing based on the two imaging positionssatisfying the target precision P′ calculated by the predeterminedprecision position calculating unit 17:

-   -   movement and capturing by the vision sensor 2 according to the        imaging control unit 11;    -   calculation of the position of the workpiece W by the area        specifying unit 12, the imaging position information acquiring        unit 13, and the position calculating unit 14; and    -   calculation and determination of the measurement precision of        the workpiece W by the precision calculating unit 15 and the        precision determining unit 16.

If the measurement precision of the workpiece W does not satisfy thetarget precision, the machine control device 10 may repeat the followingprocessing until the target precision is obtained:

-   -   calculation of two imaging positions that satisfy the target        precision P′ by the predetermined precision position calculating        unit 17;    -   movement and capturing by the vision sensor 2 according to the        imaging control unit 11;    -   calculation of the position of the workpiece W by the area        specifying unit 12, the imaging position information acquiring        unit 13, and the position calculating unit 14; and    -   calculation and determination of the measurement precision of        the workpiece W by the precision calculating unit 15 and the        precision determining unit 16.

When the target precision cannot be obtained even by repeating theabove-described processing a predetermined number of times, or when itis difficult to move the vision sensor 2, the machine control device 10stops the control of the relative positions of the tool T of the machinetool and the workpiece W based on the positional information of theworkpiece W calculated by the position calculating unit 14 and thepredetermined operation of the workpiece W by using the tool T.

FIG. 5 is a diagram showing an example of a program for controlling thevision sensor 2 by the machine control device 10 (left portion) andexplanations thereof (right portion). “G800” is a movement command ofthe vision sensor. “G810” is a command for starting imaging and imageprocessing (measurement of positional information and precisioninformation). As a result, the imaging control unit 11 causes the visionsensor 2 to move in a predetermined direction, and performs imaging ofthe workpiece W by the vision sensor 2 at two imaging positions of thedistance between imaging positions (inter-viewpoint distance) D. Theimaging position information acquiring unit 13 acquires two imagingpositions from the control command.

“G820” is a command for specifying a pixel of interest (specified area).As a result, the area specifying unit 12 specifies a partial area of theworkpiece W as a specified area in the two images. The column and row ofa specified pixel are entered as #100 and #101. The measurement distancerestoring unit 14 restores the measurement distance of the workpiece Was the positional information of the workpiece W based on the twoimages, the distance information between the two imaging positions, andthe parameters of the vision sensor 2 by using the stereo camera method.The measurement precision calculating unit 15 calculates the measurementprecision of the measurement distance of the workpiece W based on thetwo images, the distance information between the two imaging positions,and the parameter of the vision sensor 2.

“G830” is a command for determining whether or not the positionalinformation of the workpiece W corresponding to the pixel (#100, #101)satisfies (0.1, 0.1, 0.1) mm precision. As a result, the measurementprecision determining unit 16 determines whether or not the measurementprecision P of the workpiece W satisfies the target precision P′ in thespecified area. For example, the measurement precision determining unit16 determines whether or not the measurement data of the pixel in thecolumn #100 and the row #101 of the image satisfies the measurementprecision (0.1, 0.1, 0.1) mm. For example, if not satisfied, a numberother than 0 is entered in #8998.

“G840” is a command for calculating the imaging position required forthe target pixel (specified area) to satisfy the specified precision(target precision). As a result, the predetermined precision positioncalculating unit 17 calculates two imaging positions at which themeasurement precision P of the workpiece W satisfies the targetprecision P′ (the distance between the two imaging positions D′ ormeasurement distance H′ of the workpiece W). For example, thepredetermined precision position calculating unit 17 calculates theimaging position required for the measurement data of the pixelspecified by the column #100 and the row #101 to satisfy the specifiedprecision, and sets the next moving distance to X direction #300, Ydirection #301, and Z direction #303.

The processing is returned to the second line by the “GOTO 10” command,and the vision sensor is moved once again to perform imaging.

As described above, according to the machine control device 10 of thepresent embodiment, it is possible to improve the measurement precisionof the workpiece W, and to improve the security of the machine controldevice that controls the machine tool based on the image of theworkpiece W captured by the vision sensor 2. Further, according to themachine control device 10 of the present embodiment, when erroneousmeasurement or inability to measure due to halation or occlusion occurs,it also functions effectively.

According to the inventors of the present application, the followingknowledge is obtained.

-   -   Existing vision sensors cannot control the measurement        precision.        Measurement precision can be improved by bringing the vision        sensor close to the object; however, there are risks and        limitations.        Sensors with high resolution elements, high precision lenses are        expensive.    -   At present, there is no way for the numerical control device to        determine the measurement precision of the vision sensor.        There is no way for numerical control device to know the        measurement precision of the vision sensor.        There is no method for determining whether or not the precision        required for machining is satisfied.    -   At present, there is no mechanism for the numerical control        device to operate safely if the vision sensor lacks precision.        There is no mechanism for stopping the numerical control device        from the vision sensor.        There is no mechanism for instructing to improve the precision        of the vision sensor from the numerical control device.

In these respects, the following advantages can be obtained by themachine control device 10 of the present embodiment.

-   -   The numerical control device is able to know the measurement        precision of the vision sensor.    -   The numerical control device makes it possible to determine        whether or not the vision sensor output value satisfies the        specified precision.    -   The numerical control device is able to control (improve) the        measurement precision of the vision sensor.    -   If the measurement precision is insufficient, it is possible to        stop the numerical control device.    -   Improvement of reliability        It is possible to guarantee the measurement precision of the        vision sensor required for machining.        It is possible to use the vision sensors safely in numerical        control device.    -   Improvement of detection precision        It is possible to improve the measurement precision of the        vision sensor, and the detection precision can be improved.    -   Reduction in equipment cost        It is possible to achieve functions equivalent to stereo cameras        with a numerical control device+monocular camera+control        software (programs).

Modification Example

In FIG. 1, the machine control device 10 may not be provided with thepredetermined precision position calculating unit 17. In other words,the machine control device 10 may not perform the calculation of the twoimaging positions satisfying the target precision P′ by thepredetermined precision position calculating unit 17. In themodification example, when the measurement precision of the workpiece Wdoes not satisfy the target precision, the machine control device 10gradually widens the two imaging positions (for example, the distancebetween the two imaging positions D) until the target precision isobtained.

FIG. 6 is a diagram for explaining a calculation of two imagingpositions (moving amounts) satisfying the target precision by themachine control device 10 according to the modification example. Asshown in FIG. 6, when the measurement precision of the workpiece W doesnot satisfy the target precision, the machine control device 10according to the modification example widens the two imaging positions(for example, the distance between the two imaging positions D) by apredetermined amount (minute amount) until the target precision isobtained. The predetermined amount (minute amount) may be apredetermined amount and may be stored in, for example, a storage unitor the like. Alternatively, in the same manner as described above, themachine control device 10 according to the modification example maybring two imaging positions (for example, the measurement distance H ofthe workpiece W) close to the workpiece W by a predetermined amount(minute amount).

In other words, if the measurement precision of the workpiece W does notsatisfy the target precision, the machine control device 10 of themodification example repeats the following processing until the targetprecision is obtained:

-   -   changing of the imaging position by a predetermined amount        (minute amount);    -   movement and capturing by the vision sensor 2 according to the        imaging control unit 11;    -   calculation of the position of the workpiece W by the area        specifying unit 12, the imaging position information acquiring        unit 13, and the position calculating unit 14; and    -   calculation and determination of the measurement precision of        the workpiece W by the precision calculating unit 15 and the        precision determining unit 16.

FIG. 7 is a diagram showing an example of a program for controlling thevision sensor 2 by the machine control device 10 according to themodification example (left portion) and explanations thereof (rightportion). The program shown in FIG. 7 differs in the position of the“G800” from the program shown in FIG. 5.

“G800” is a movement command of the vision sensor. For example, thevision sensor is moved in the X direction by a predetermined movingdistance (for example, an initial value or a user specification)included in #200.

Although embodiments of the present invention have been described above,the present invention is not limited to the embodiments described above,and various modifications and variations are possible. For example, inthe embodiment described above, the machine control device for measuringthe position of an object based on an image including the object imagedby the vision sensor is exemplified; however, the present invention isnot limited to this, and the present invention is applicable to amachine control device for measuring the position of an object based onan image including the object imaged by various imaging devices.Examples of such various imaging devices include a monocular camera, astereo camera capable of three-dimensional measurement, and athree-dimensional camera. Even with the stereo cameras andthree-dimensional cameras, the measurement precision can be improved bybringing them close to the object.

Further, in the embodiment described above, the machine control devicefor controlling the position with respect to the object based on twoimages including the object imaged at two imaging positions isexemplified; however, the present invention is not limited to this, andthe present invention is applicable to a machine control device forcontrolling the position with respect to the object based on three ormore images including the object imaged at three or more imagingpositions. In this case, it may be configured to determine the imagingposition as a reference, and, it may be configured, for each imagingposition of the object, to restore the measurement distance of theobject as the positional information of the object as described above(the measurement distance restoring unit), calculate the measurementprecision of the measurement distance of the object (the measurementprecision calculating unit), determine whether the measurement precisionof the object satisfies a predetermined precision (the measurementprecision determining unit), calculate the distance information betweenthe two imaging positions or the measurement distance of the object atwhich the measurement precision of the object satisfies a predeterminedprecision (predetermined precision calculation unit), control theposition and orientation of the imaging device based on the distanceinformation between the two imaging positions or the measurementdistance of the object calculated by the predetermined precisionposition calculating unit, and change the imaging position with respectto the reference (the distance between the two imaging positions or themeasurement distance of the object).

Further, in the above-described embodiment, the numerical control deviceof the machine tool for performing a predetermined operation on aworkpiece by controlling the relative position of a workpiece and a toolattached to the machine tool is exemplified. However, the presentinvention is not limited to this, and the present invention can beapplied to various types of machine control devices such as a robotcontrol device for performing a predetermined operation on a workpieceby controlling the relative positions of a workpiece and a tool or ahand attached to an industrial robot. In this case, when the imagingdevice is attached to the arm of the robot, the movement command of thearm of the robot and the movement command of the imaging device can bemade identical.

EXPLANATION OF REFERENCE NUMERALS

-   -   2 vision sensor (imaging device)    -   10 machine control device    -   11 imaging control unit    -   12 area specifying unit    -   13 imaging position information acquiring unit    -   14 measurement distance restoring unit    -   15 measurement precision calculating unit    -   16 measurement precision determining unit    -   17 predetermined precision position calculating units

What is claimed is:
 1. A machine control device that controls a machineperforming a predetermined operation on an object, the machine controldevice being configured to control a relative position of the machineand the object based on an image including the object imaged by animaging device, the machine control device comprising: an imagingcontrol unit that controls a position and orientation of the imagingdevice, and controls the imaging device to capture two or more imagesincluding the object at two or more different imaging positions based ona control command; an imaging position information acquiring unit thatacquires positional information of the two or more imaging positions; ameasurement distance restoring unit that restores a measurement distanceof the object as positional information of the object based on at leasttwo images among the two or more images, distance information between atleast two imaging positions corresponding to the at least two imagesamong the two or more imaging positions, and a parameter of the imagingdevice, by using a stereo camera method; a measurement precisioncalculating unit that calculates a measurement precision of themeasurement distance of the object based on the at least two images, thedistance information between the at least two imaging positions, and theparameter of the imaging device; an area specifying unit that specifiesa partial area of the object as a specified area; and a measurementprecision determining unit that determines whether the measurementprecision of the object satisfies a predetermined precision in thespecified area.
 2. The machine control device according to claim 1,wherein the measurement distance restoring unit obtains parallaxinformation Z for each pixel by performing area matching on the at leasttwo images, and calculates a measurement distance H of the object byequation (1) below based on the parallax information Z for the eachpixel, distance information between the at least two imaging positionsD, and a focal distance f which is the parameter of the imaging device,and the measurement precision calculating unit calculates a measurementprecision P of the measurement distance of the object by equation (2)below, which calculates a difference of the measurement distance H froman adjacent pixel by differentiating the measurement distance H by theparallax information Z,H=D×f/Z  (1),P=|dH/dZ|=D×f/Z ² =H ²/(D×f)  (2).
 3. The machine control deviceaccording to claim 1, wherein when the measurement precision of theobject does not satisfy the predetermined precision, the machine controldevice stops control of the machine.
 4. The machine control deviceaccording to claim 1, wherein when the measurement precision of theobject does not satisfy the predetermined precision, the machine controldevice controls the position and orientation of the imaging device andchanges at least one of the at least two imaging positions so as toenhance the measurement precision of the object.
 5. The machine controldevice according to claim 4, wherein when the measurement precision ofthe object does not satisfy the predetermined precision, the machinecontrol device controls the position of the imaging device in adirection increasing a distance between the at least two imagingpositions or in a direction bringing the imaging position close to theobject to thereby enhance the measurement precision of the object. 6.The machine control device according to claim 4, further comprising: apredetermined precision position calculating unit that calculatesdistance information between the at least two imaging positions at whichthe measurement precision of the object satisfies a predeterminedprecision based on the at least two images, the measurement distance ofthe object, and the parameter of the imaging device, or calculates ameasurement distance of the object at which the measurement precision ofthe object satisfies a predetermined precision based on the at least twoimages, the distance information between the at least two imagingpositions, and the parameter of the imaging device in the specifiedarea, wherein the machine control device controls the position andorientation of the imaging device based on the distance informationbetween the at least two imaging positions or the measurement distanceof the object calculated by the predetermined precision positioncalculating unit, and changes at least one of the at least two imagingpositions.
 7. The machine control device according to claim 6, whereinthe measurement distance restoring unit obtains parallax information Zfor each pixel by performing area matching on the at least two images,and calculates a measurement distance H of the object by equation (1)below based on the parallax information Z for the each pixel, distanceinformation between the at least two imaging positions D, and a focaldistance f which is a parameter of the imaging device, and thepredetermined precision position calculating unit calculates a distanceD′ between the at least two imaging positions at which the measurementprecision of the object satisfies a predetermined precision P′ byequation (3) below based on a measurement distance H of the object and afocal distance f which is a parameter of the imaging device, orcalculates a measurement distance H′ of the object at which themeasurement precision of the object satisfies the predeterminedprecision P′ by a following equation (4) based on the distance betweenthe at least two imaging positions D and the focal distance f which isthe parameter of the imaging device,H=D×f/Z  (1),P′=H ²/(D′×f)  (3),P′=H′ ²/(D×f)  (4).